package com.foreveross.vo;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.format.annotation.DateTimeFormat;

/**
 * Message entity. @author MyEclipse Persistence Tools
 */
@Entity
@Table(name = "message", catalog = "hrtenement")
public class Message implements java.io.Serializable {

	// Fields

	private String id;
	private String title;
	private String content;
	private SysUser createUser;
	@DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
	private Date createDate;
	private Integer isAll;
	private List<MessageHouse> messageHouses = new ArrayList<MessageHouse>();

	// Constructors

	/** default constructor */
	public Message() {
	}

	/** minimal constructor */
	public Message(String id) {
		this.id = id;
	}

	/** full constructor */
	public Message(String id, String title, String content, SysUser createUser,
			Date createDate,Integer isAll) {
		this.id = id;
		this.title = title;
		this.content = content;
		this.createUser = createUser;
		this.createDate = createDate;
		this.isAll = isAll;
	}

	// Property accessors
	@Id
	@GenericGenerator(name="idGenerator", strategy="uuid")
	@GeneratedValue(generator="idGenerator") 
	@Column(name = "id", unique = true, nullable = false, length = 32)
	public String getId() {
		return this.id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "title")
	public String getTitle() {
		return this.title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	@Column(name = "content")
	public String getContent() {
		return this.content;
	}

	public void setContent(String content) {
		this.content = content;
	}
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "create_user")
	@NotFound(action=NotFoundAction.IGNORE)
	public SysUser getCreateUser() {
		return this.createUser;
	}

	public void setCreateUser(SysUser createUser) {
		this.createUser = createUser;
	}

	@Column(name = "create_date")
	public Date getCreateDate() {
		return this.createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	@Column(name = "is_all")
	public Integer getIsAll() {
		return isAll;
	}

	public void setIsAll(Integer isAll) {
		this.isAll = isAll;
	}

	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "message")
	public List<MessageHouse> getMessageHouses() {
		return messageHouses;
	}

	public void setMessageHouses(List<MessageHouse> messageHouses) {
		this.messageHouses = messageHouses;
	}

}